public class zyz175204 {
   public static void main(String args[]) {
      CargoBoat ship = new CargoBoat();
      ship.setMaxContent(1000);
      int m =600;
      try{  
           ship.loading(m);
           m = 400;
           ship.loading(m);
           m = 204;
           ship.loading(m);
           m = 367;
           ship.loading(m);
           m = 555;
           ship.loading(m);
      }
      catch(DangerException e) {
           System.out.println(e.warnMess()); 
           System.out.println("无法再装载重量是"+m+"吨的集装箱");       

      }
catch(DangerException2 e) {
           System.out.println(e.warnMess()); 
           System.out.println("min重量是"+m+"吨的集装箱");       

      }
      finally {
          System.out.printf("货船将正点启航");
      }
  }
}
class DangerException extends Exception {
   final String message = "超重";
   public String warnMess() {
       return message;
   }
} 
class DangerException2 extends Exception {
   final String message = "超轻";
   public String warnMess() {
       return message;
   }
} 
class CargoBoat {
     int realContent;  //装载的重量
     int maxContent;   //最大装载量
    int minContent;
     public void setMaxContent(int c) {
         maxContent = c;
     }
public void setMinContent(int c) {
         minContent = c;
     }
public void loading(int m) throws DangerException2 {
       realContent += m;
       if(realContent<minContent) {
          throw new DangerException2(); 
       }
       System.out.println("目前装载了"+realContent+"吨货物");
     }
     public void loading(int m) throws DangerException {
       realContent += m;
       if(realContent>maxContent) {
          throw new DangerException(); 
       }
       System.out.println("目前装载了"+realContent+"吨货物");
     }
}
